package com.ews.onlineexchange.service;

import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;

import com.ews.onlineexchange.model.AgentService;
import com.ews.onlineexchange.model.MainBusiness;
import com.ews.onlineexchange.model.ServiceSupplier;

@Named
@ConversationScoped
public class EjbServiceSupplierHome extends EntityHome<ServiceSupplier, String> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public void addAgentService(AgentService agentService) {
		MainBusiness firstMainBusiness = getInstance().getMainBusinesses().get(0);
		MainBusiness mainBusiness = firstMainBusiness;
		if (mainBusiness.getAgentService() != null) {
			mainBusiness = new MainBusiness();
			mainBusiness.setCommitOfPrice(firstMainBusiness.getCommitOfPrice());
			mainBusiness.setCommitOfQuality(firstMainBusiness.getCommitOfQuality());
			mainBusiness.setCommitOfTime(firstMainBusiness.getCommitOfTime());
			mainBusiness.setAgentServiceDetail(agentService.getName());
			getInstance().getMainBusinesses().add(mainBusiness);
		}
		mainBusiness.setAgentService(agentService);
	}

}
